import { findFilmsPage } from '@/api/MaiZuo';
const clearFilmList = () => {
  return { type: 'clear-filmList' };
};

// redux-promise
const getFilmList = async (cityId = 110100) => {
  const res = await findFilmsPage(1, 10, 1, cityId);
  return {
    type: 'change-filmList',
    payload: res.films || [],
  };
};

const addFilmList = async (
  pageNum = 1,
  pageSize = 10,
  type = 1,
  cityId = 110100
) => {
  const { films = [], total } = await findFilmsPage(
    pageNum,
    pageSize,
    type,
    cityId
  );
  return {
    type: 'add-filmList',
    payload: {
      films,
      total,
    },
  };
};

export { clearFilmList, getFilmList, addFilmList };
